#include "shellSort.h"
#include "contador.h"
#include<stdio.h>
#include<stdlib.h>

void shellSort( int * vet, int size, long cont[] ){  
         Contador shellContador;
         int i , j , value;
         int gap = 1;
         cont[0] = -2;//dentro do do-while, o primeiro loop nao tem comparacao
         
         do {
            gap = 3*gap+1;
         } while ( gap < size );
	     do {
		    gap /= 3;
		    for ( i = gap; i < size; i++ ){
                
			    value =vet[i];
       			j = i - gap;
			    while ( j >= 0 && value < vet[j] ){
                      cont[0]++;
                      cont[1]++;
				      vet [j + gap] =vet[j];
				      j -= gap;
			    }
			    cont[1]++;
			    vet [j + gap] = value;
		    }
	     } while ( gap > 1);
}

  
